﻿namespace DimensionsHelper.LanguageService.Syntax;

public class MetadataLabel : MetadataArealObject
{
    private StringLiteral? _labelText;

    internal MetadataLabel(SyntaxNode? parent) :
        base(SyntaxKinds.MetadataLabel, parent)
    {
    }

    /// <summary>
    ///     元数据描述的字符串，如果是 - ，设置此值为 null。
    /// </summary>
    public StringLiteral? LabelText => _labelText;


    public MetadataLabel Update(StringLiteral? labelText)
    {
        SetChildNullableField(ref _labelText, labelText);
        return this;
    }


    public override void AcceptVisitor<T>(SyntaxNodeVisitor<T> visitor)
    {
        Accept(visitor, AreaName, LabelText);
    }
}


public static partial class NodeFactory
{
    public static MetadataLabel CreateMetadataLabel(SyntaxNode? parent, Identifier? arealName, StringLiteral? text)
    {
        MetadataLabel label = new(parent);
        if (arealName != null)
        {
            label.Update(arealName);
        }

        return label.Update(text);
    }
}